﻿using System;

public class AllInOne
{
    public static void Main()
    {
        int current;
        int problem;

        do
        {
            ConsolePreparation(0, 15);
            problem = -1;
            Console.Write("\nList of all problems :\n\n" 
                                            + "1. Decimal to Binary conversion\n"
                                            + "2. Binary to Decimal conversion\n"
                                            + "3. Decimal to Hexadecimal conversion\n"
                                            + "4. Hexadecimal to Decimal conversion\n"
                                            + "5. Hexadecimal to Binary Directly conversion\n"
                                            + "6. Binary to Hexadecimal Directly conversion\n"
                                            + "7. Conversion between Numeral Systems\n"
                                            + "8. Binary representation of 'short' number\n" 
                                            + "\n---------------------------------------------------\n" 
                + "\nEnter the number of \"Problem [1, 8]\", that you want to test : ");
            if (!(int.TryParse(Console.ReadLine(), out current) && (1 <= current) && (current <= 8)))
                continue;

            do
            {
                problem = current;
                if (problem == 0)
                    break;

                Console.Clear();
                switch (problem)
                {
                    case 1:
                        { 
                            try { ConsolePreparation(15, problem); DecimalToBinaryConversion.Main(); }
                                catch (ArgumentException argEx) { Console.WriteLine("\n{0}", argEx.Message); }
                            break;
                        }
                    case 2:
                        {
                            try { ConsolePreparation(15, problem); BinaryToDecimalConversion.Main(); }
                                catch (ArgumentException argEx) { Console.WriteLine("\n{0}", argEx.Message); }
                            break;
                        }
                    case 3:
                        {
                            try { ConsolePreparation(15, problem); DecimalToHexadecimalConversion.Main(); }
                                catch (ArgumentException argEx) { Console.WriteLine("\n{0}", argEx.Message); }
                            break;
                        }
                    case 4:
                        {
                            try { ConsolePreparation(15, problem); HexadecimalToDecimalConversion.Main(); }
                                catch (ArgumentException argEx) { Console.WriteLine("\n{0}", argEx.Message); }
                            break;
                        }
                    case 5:
                        {
                            try { ConsolePreparation(15, problem); HexadecimalToBinaryDirectlyConversion.Main(); }
                                catch (ArgumentException argEx) { Console.WriteLine("\n{0}", argEx.Message); }
                            break;
                        }
                    case 6:
                        {
                            try { ConsolePreparation(15, problem); BinaryToHexadecimalDirectlyConversion.Main(); }
                                catch (ArgumentException argEx) { Console.WriteLine("\n{0}", argEx.Message); }
                            break;
                        }
                    case 7:
                        {
                            try { ConsolePreparation(15, 12); ConversionBetweenNumeralSystems.Main(); }
                                catch (ArgumentException argEx) { Console.WriteLine("\n{0}", argEx.Message); }
                            break;
                        }
                    case 8:
                        {
                            try { ConsolePreparation(15, problem); BinaryRepresentationOfShortNumber.Main(); }
                                catch (ArgumentException argEx) { Console.WriteLine("\n{0}", argEx.Message); }
                            break;
                        }
                    default: break;
                }

                Console.Write("\nEnter the number of \"Problem [1, 8]\", that you want to test,"
                    + "\n   enter 0 to show Tasks Menu," 
                        + "\n      or anything else to restart \"Problem {0}\" ...", problem);
                if (int.TryParse(Console.ReadLine(), out problem) && (0 <= problem) && (problem <= 8))
                    current = problem;
            } while (true);
        } while (true);
    }

    public static void ConsolePreparation(int background, int foreground)
    {
        Console.BackgroundColor = (ConsoleColor)background;
        Console.ForegroundColor = (ConsoleColor)foreground;
        Console.Clear();
    }
}